package pool.preprocess.operation;

import java.util.Hashtable;

import logger.ProcessLogger;
import calculation.Calculation;

import pool.tablename.Pool;
import database.RecordSearch;
import dbmanager.Column;
import dbmanager.DBManager;

public class Expression implements Operation
{	
	String object;
	public Pool pool;
	public DBManager database;
	RecordSearch rs;
	public String tablename;
	public String result[];
	
	
	public void getResult() 
	{
		Hashtable<Object, Object> Condition = new Hashtable<Object, Object>();
		Condition.put("mid", object);
		Condition.put("td", "null"); 
		rs.setConditionMap(Condition);
		result = rs.getArrayFromResultSet();
		ProcessLogger processlogger = new ProcessLogger(database);
		result =processlogger.sortArrayIndex(result, Column.ref_index-1);
		Calculation calculation = new Calculation(this);
		calculation.Calculation expr =  calculation.getResult();
		pool.setHashtable(expr.TransactionDetailMap);
		pool.setmasterHashtabel(expr.TransactionMap);
	}

	
	public void setDbmanager(DBManager database) 
	{	
		this.database = database;
		rs =new RecordSearch(database);
	}

	
	public void setObject(String object,Pool pool,String tablename) 
	{	
		this.object = object;
		this.pool = pool;
		this.tablename = tablename;
	}

}
